<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title></title>
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    <style>
        table tr td{
            text-align: center;
        }
    </style>
</head>
<body>
<h3>书籍列表</h3>

<table cellpadding="10" cellspacing="30">
    <thead>
        <th>书名</th>
        <th>价格</th>
        <th>ISBN</th>
        <th>作者</th>
        <th>上架时间</th>
        <th>是否下架</th>
        <th>编辑</th>
    </thead>
    <tr th:each="book: ${bookList}">
        <td th:text="${book.name}"></td>
        <td th:text="${book.price}"></td>
        <td th:text="${book.isbn}"></td>
        <td th:text="${book.author}"></td>
        <td th:text="${book.createdTime}"></td>
        <td th:if="${book.expired == 0}">下架</td>
        <td th:if="${book.expired == 1}">有货</td>
        <td>
            <a th:href="@{/book/updateInput(isbn=${book.isbn})}" id="modiry_book">修改</a>
            <a th:href="@{/book/del(isbn=${book.isbn})}" class="del_book">删除</a>
        </td>
    </tr>
</table>

<div>
    <button id="add_new_book" onclick="javascript:window.location.href='/book/addInput'">新增图书</button>
</div>

<script type="text/javascript">
    $(function(){
        $('.del_book').click(function(){
            if(confirm("确定要删除此书吗?")){
                return true;
            }
            return false;
        });

    })
</script>
</body>
</html>